<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>photo</title>
<link href="../Public/css/index.css" rel="stylesheet" type="text/css" />
<link href="../Public/css/member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function deletePhoto(id) {
	if(confirm('确定要删除照片吗?')) {
		if("{$headPic['photo_id']}"!=id) window.location="__URL__/photodelete/photoid/"+id; 
		else alert("头像照片不能直接删除!\n请先设置其他照片为头像再删除该照片");
	}
}
function setHeadPic(id) {
	window.location="__URL__/headpicmodify/photoid/"+id;
}
function uploadCheck() {
	var filepath = document.getElementById("uploadPhoto").value;
    if(filepath==""){
    	alert("请选择上传的文件！");
    	return false;
  	}
    var extname = filepath.substring(filepath.lastIndexOf(".")+1,filepath.length);
    extname = extname.toLowerCase();//处理了大小写
    if(extname!= "bmp"&&extname!= "jpg"&&extname!= "gif"){
     	alert("只能上传bmp,jpg,gif格式的图片！");
      	return false;
     }
    return true;
}
function init() {
	var head_pic = document.getElementById("{$headPic['photo_id']}");
	head_pic.innerHTML = "[<span style='color:#FF7F00'>当前头像</span>][<a onclick='deletePhoto(\"{$headPic['photo_id']}\");'>删除</a>]";
}
</script>
</head>
<body onload="init()">
<form action="photoupload" enctype="multipart/form-data" method="post" onsubmit='return uploadCheck();'>
<div id="member_info_main">
	<div id="member_info_upfile">上传文件： 
		<input type="file" name="uploadPhoto" id="uploadPhoto"/> 
		<input name="headpic" type="checkbox" value="1" />设为头像 
		<input type="submit" value="上传" />
		<span class="member_image_notice">*点击图片可查看大图</span>
	</div>
	<div id="member_info_image">
		<volist name="photolist" id="photo">
		<div id="member_photo">
			<a href="__PUBLIC__/Uploads/photos/{$photo.photo_url}" target=_blank>
			<img src="__PUBLIC__/Uploads/photos/{$photo.photo_url}"
			width="90px" height="120px" /></a><br />	
			<span class="member_image_font" id="{$photo.photo_id}">
			[<a onclick="setHeadPic('{$photo.photo_id}')">设为头像</a>][<a onclick="deletePhoto('{$photo.photo_id}')">删除</a>]</span>
		</div>
		</volist>
	</div>
	<div id="member_page">{$page}</div>
</div>
</form>
</body>
</html>